public class search2 {
    public int search2(int[] nums, int target) {
        int low = 0,high = nums.length - 1;
        while(low <= high){
            int mid = (high - low + 1 ) / 2 + low;
            if(target == nums[mid]){
                return mid;
            }
            if(nums[low] <= nums[mid]){
                if(nums[low] <= target && target < nums[mid]){
                    high = mid - 1;
                }else{
                    low = mid + 1;
                }
            }else{
                if(nums[mid] < target && target <= nums[high] ){
                    low = mid + 1;
                }
                else{
                    high = mid - 1;
                }
            }
        }
        return -1;
    }
}
